package com.jxtech.hp.vdps.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * 根据本机ip获取资源请求地址
 * @author luojing
 * @create 2019/01/08 1:46 PM
 **/
public class RequestUtils {


  /**
   * @param filePath 基于uploadPath,如果 uploadPath 下有/doc/a.txt,那么filePath传 uploadPath + doc/a.txt
   */
  public static String getLocalUrl(String port, String filePath, HttpServletRequest request) {
    return getLocalUrl(port,request) + filePath;
  }

  public static String getLocalUrl(String port, HttpServletRequest request) {
    return request.getScheme() + "://" + request.getServerName() + ":" + port;
  }
}
